home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 August / Ahoy_Magazine_85-08_1985_Double_L.d64 / birthday calc (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  910b  |  37 lines

  1. 0 rem << rr20-2 >>
  2. 1 rem
  3. 2 rem  --  birthday calc  --
  4. 3 rem    rupert report #20
  5. 4 rem
  6. 10 rem - calculate the probability
  7. 11 rem   that for a group of np people
  8. 12 rem   two or more of them were born
  9. 13 rem   on the same day of the year
  10. 14 rem
  11. 20 print chr$(147):poke53280,7:poke53281,9:poke646,7
  12. 30 print "how many people are in the room":print"(enter 0 for complete list)"
  13. 40 input np
  14. 50 if np<=0 or int(np)<>np then 200
  15. 60 pf=1    :rem probability of failure
  16. 70 for q=1 to np
  17. 80 pf=(367-q)*pf/366 : next
  18. 90 ps=1-pf :rem probability of success
  19. 100 print
  20. 110 print"in a group of" np "people,"
  21. 120 print"there is a" ps*100 "percent"
  22. 130 print"probability that two or more"
  23. 140 print"people have the same birthday"
  24. 150 print
  25. 160 goto 30
  26. 200 pf=1
  27. 210 for np=1 to 366
  28. 220 pf=pf*(367-np)/366
  29. 230 print "# people ="np;
  30. 240 print "   % prob. =" (1-pf)*100
  31. 245 rem  count # of lines listed (nl)
  32. 250 nl=nl+1 : if nl<20 then 290
  33. 260 nl=0
  34. 270 print "press any key for more..."
  35. 280 get x$:if x$="" then 280
  36. 290 next
  37.